#include <stdio.h>
int main(void)
{
    int top, bottom, m, n;
    printf("Enter a faction: ");
    scanf("%d /%d", &top, &bottom);
    m = top;
    n = bottom;
    if (m < n) {
        m = m + n;
        n = m - n;
        m = m - n;
    }
    while (n != 0) {
        m = m % n;
        m = m + n;
        n = m - n;
        m = m - n;
    }
    top /= m;
    bottom /= m;
    if (bottom == 1)
        printf("In lowest terms: %d\n", top);
    else
        printf("In lowest terms: %d/%d\n", top, bottom);
    return 0;
}